<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">

<head>
    <th:block th:include="common/common_head :: commonHeader('新增环保承诺书')"/>
    <link rel="stylesheet" th:href="@{/static/js/plugins/jquery-layout/jquery.layout-latest.css}">
</head>
<body class="gray-bg">
<div class="container-div ui-layout-center">
    <div class="row">
        <div class="form-group">
            <div class="col-sm-8" style="margin-left: 16px">
                <input class="btn btn-primary" type="button" onclick="save()" value="保存">
                <button class="btn btn-primary" type="button" onclick="Dialog.closeFrame(window.name)">取 消</button>
            </div>
        </div>
        <div class="col-sm-12" align="centre" style="margin-top: 10px">
            <form class="ibox-content form-horizontal" method="post" id="environCommitFrom" enctype="multipart/form-data">
                <div class="form-group row">
                    <label class="col-xs-1 control-label"><span class="required-sign">*</span>供应商代码：</label>
                    <div class="col-xs-3">
                        <input class="form-control" name="vendorCode" type="text"  th:value="${vendorCode}" th:if="${vendorCode} != null" disabled >
                        <input class="form-control" name="vendorCode" type="text"  placeholder="供应商代码" th:if="${vendorCode} == null" required autocomplete="off">
                    </div>
                    <label class="col-xs-1 control-label"><span class="required-sign">*</span>供应商名称：</label>
                    <div class="col-xs-3">
                        <input class="form-control" name="vendorName" type="text" th:value="${vendorName}"  th:if="${vendorName} != null" disabled>
                        <input class="form-control" name="vendorName" type="text" placeholder="供应商名称" th:if="${vendorName} == null" required autocomplete="off">
                    </div>
                </div>
                <div class="form-group row">
                    <label class="col-xs-1 control-label"><span class="required-sign">*</span>保证书编号：</label>
                    <div class="col-xs-3">
                        <input name="guaranteeCode" required type="text" placeholder="保证书编号" class="form-control" autocomplete="off">
                    </div>
                    <label class="col-xs-1 control-label"><span class="required-sign">*</span>合同签订日期：</label>
                    <div class="col-xs-3">
                        <input type="text" name="contractDate" required id="contractDate" autocomplete="off" class="form-control">
                    </div>
                </div>
                <div class="form-group row">
                    <label class="col-xs-1 control-label"><span class="required-sign">*</span>类别：</label>
                    <div class="col-xs-3">
                        <select name="type" sysDict="HBCNSLX" emptyFirst="true" class="form-control" required></select>
                    </div>
                    <label class="col-xs-1 control-label"><span class="required-sign">*</span>附件（环保承诺书、加盖公章)：</label>
                    <div class="col-xs-3">
                        <input type="file" name="attachFile" required class="form-control">
                    </div>
                </div>
                <div class="form-group row">
                    <label class="col-xs-1 control-label"><span class="required-sign">*</span>录入人：</label>
                    <div class="col-xs-3">
                        <input name="editor" required type="text" placeholder="录入人" class="form-control" autocomplete="off">
                    </div>
                    <!--<label class="col-xs-1 control-label"><span class="required-sign">*</span>录入时间：</label>
                    <div class="col-xs-3">
                        <input type="text" name="editDate" required id="editDate" class="form-control" autocomplete="off" >
                    </div>-->
                </div>
                <div class="form-group row">
                    <label class="col-xs-1 control-label">注意事项：</label>
                    <div class="col-xs-7">
                        <span style="color: red;line-height: 2em;">
                            1.环保承诺书：指厚声合作伙伴与厚声签订的合约书，注意要盖章备案的生效版<br>
                            2.环保承诺书版本：需合作伙伴签订最新版本，最新版本请在平台“管理表单”上下载<br>
                            3.系统提交及审核权限：提交人-合作伙伴质量经理；审核人-厚声SQE马东，联系邮箱：sqe@uniohm.com.电话：0512-57631411-8832
                        </span>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<!--引入公共js-->
<div th:include="common/onload_js :: onloadJS"></div>
<script type="text/javascript" th:src="@{/static/js/plugins/jquery-layout/jquery.layout-latest.js}"></script>

<script type="text/javascript">

    $(function () {
        // 初始化时间插件
        laydate.render({elem: '#contractDate'});
        //laydate.render({elem: '#editDate'});
        //初始化所有字典数据
        initDictDataSel();
    });

    //保存提交的数据
    function save(){
        if($("#environCommitFrom").valid()) {

            //合同签订日期不能晚于今天
            var contractDate=new Date($("#contractDate").val());
            if(contractDate>new Date()){
                Dialog.errorMsg("合同签订日期不能晚于今天！");
                return ;
            }

            var formData = new FormData($('#environCommitFrom')[0]);
            layer.load(1, {shade: [0.3, '#393D49']});
            $.ajax({
                url: ctxPath + "/environCommitment/save",
                type: 'POST',
                data: formData, // 上传formdata封装的数据包
                dataType: 'JSON',
                cache: false, // 不缓存
                processData: false, // jQuery不要去处理发送的数据
                contentType: false, // jQuery不要去设置Content-Type请求头
                success: function (data) {
                    layer.closeAll();
                    if (data.code==0) {
                        Dialog.msg("操作成功!");
                        parent.refresh();
                        Dialog.closeFrame(window.name);
                    } else {
                        Dialog.errorMsg("操作失败，请重试!");
                    }
                }
            });
        }
    }
</script>

</body>
</html>